﻿@model IEnumerable<Zatify.Domain.Data.Message>
@{
    ViewBag.Title = "Message Center Outbox";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
@section Styles
{
    <link href="@Url.Content("~/Areas/Admin/Content/zatify/Css/pop_ups.css")" rel="stylesheet" type="text/css" />
}
@section Scripts
{
    <script src="@Url.Content("~/Areas/Admin/Scripts/pop_ups.js")" type="text/javascript"></script>
    <script type="text/javascript">
        
        var blockReadMessage;

        $(document).ready(function () {
        
            blockReadMessage = $("#blockReadMessage");
        });

        function showBlockReadMessage(id) {

             $.ajax({
                        url: "@Url.Action("GetMessage", "MessageCenter")",
                        type: 'GET',
                        data: { id: id },
                        success: function (result) {

                            var message = result.message;

                            if(!result.hasError){

                                $("#ReadonlyBody").val(message.Body);

                                if(blockReadMessage.css("display") == "none")
                                    blockReadMessage.slideToggle("slow");
                            }
                            else{

                                alert(message);
                            }
                        },
                        error: function(){
                        
                            alert("Error occured durrin Ajax request");
                        }
                    });
        }

        function closeReadPopup()
        {
            readMessagePopUp.ClosePopUp();
        }

    </script>
}
<!--start bradecums-->
<div class="bradecums_bar">
    Message Center <span>&raquo;</span> Outbox <span>
</div>
<!--end bradecums-->
<!--start button-->
<div class="zatify_panel_btn2 z_margin_bottom20px">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>
                <a href="@Url.Action("Inbox", "MessageCenter")" style="text-decoration:none">
                    <input name="" type="button" class="btn apps_btn apps_gray_btn" value="Inbox" />
                </a><a href="@Url.Action("Outbox", "MessageCenter")" style="text-decoration:none">
                    <input name="" type="button" class="btn apps_btn apps_gray_btn" value="Outbox" />
                </a><a href="@Url.Action("Compose", "MessageCenter")" style="text-decoration: none">
                    <input name="" type="button" class="btn apps_btn apps_gray_btn" value="Compose" />
                </a>
            </td>
        </tr>
    </table>
    <div class="clearfix">
    </div>
</div>
<!--end button-->
<!--starts search results-->
<div class="search_result_bd">
    <!--<h4>Search Results</h4>-->
    <div class="zatify_table_content">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <th width="10%">
                    Action
                </th>
                <th width="20%">
                    To
                </th>
                <th width="20%">
                    Date
                </th>
                <th width="50%">
                    Subject
                </th>
            </tr>
            @foreach (var message in Model)
            {
                <tr>
                    <td>
                        <a href="@Url.Action("DeleteOutbox", "MessageCenter", new { messageId = @message.MessageId })" onclick="return confirm('Delete selected message?')">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/cancel_icon.png")" alt="" title="Delete" border="0" /></a>
                    </td>
                    <td>
                        @message.ToUserLogin
                    </td>
                    <td>
                        @message.CreatedDate
                    </td>
                    <td>
                        <a href="#" onclick="showBlockReadMessage(@message.MessageId); return false;">
                            @message.Subject
                        </a>
                    </td>
                </tr>
            }
        </table>
    </div>
</div>
<div class="clearfix">
</div>
<!--end search results-->
<!--start add new part-->
<div id="blockReadMessage" style="display: none;" class="add_new_zatify_user">
    <div class="z_messages_area">
        <h5>
            Message Body:</h5>
        @Html.TextArea("ReadonlyBody", new { @class = "z_messages_box_full", @readonly = "readonly" })
    </div>
</div>
<div class="clearfix">
</div>
<!--end add new part-->
